package com.tangbuzhi.facade;

/**
 * 外观模式
 */
public class Facade {
    private static class SubSystemA {
        private void start() {
            System.out.println("sub system A start");
        }

        private void end() {
            System.out.println("sub system A end");
        }
    }

    private static class SubSystemB {
        private void start() {
            System.out.println("sub system B start");
        }

        private void end() {
            System.out.println("sub system B end");
        }
    }

    private static class SubSystemC {
        private void start() {
            System.out.println("sub system C start");
        }

        private void end() {
            System.out.println("sub system C end");
        }
    }

    public static class SystemFacade {
        private static SubSystemA subSystemA = new SubSystemA();
        private static SubSystemB subSystemB = new SubSystemB();
        private static SubSystemC subSystemC = new SubSystemC();

        private void start() {
            subSystemA.start();
            subSystemB.start();
            subSystemC.start();
        }

        private void end() {
            subSystemA.end();
            subSystemB.end();
            subSystemC.end();
        }
    }

    public static void main(String[] args) {
        SystemFacade systemFacade = new SystemFacade();
        systemFacade.start();
        systemFacade.end();
        /**
         sub system A start
         sub system B start
         sub system C start
         sub system A end
         sub system B end
         sub system C end
         */
    }
}
